<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>音乐排行榜</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <script src="./lib/vue-resource-1.3.4.js"></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="app">
        <div class="nav">
            <ul class="w clearfix">
                <li><a href="home.html">首页</a></li>
                <li><a href="index.html">音乐排行榜</a></li>
                <li><a href="search.html">音乐搜索</a></li>
            </ul>
        </div>
        
        <div class="container w">
            <ul>
                <li v-for="item in list" :key="item.sid" >
                        
                        <div class="content" @click="link(item.type)">
                            <div class="cover">
                                <img :src="item.pic_s210" alt="">
                            </div>
                            <div class="cnt-r" :style="{background:'url('+item.bg_pic+') no-repeat center'}">
                                <h3>{{item.name}}</h3>
                                <p class="desc">
                                        {{item.comment}}
                                </p>
                                <p>
                                        歌曲数量:{{item.count}}
                                </p>
                            </div>
                        </div>
                    </li>
            </ul>
        </div>
    </div>
</body>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            list:[]
        },
        methods:{
            link(type){
                location.href=`list.html#type=${type}`
            }
        },
        //生命周期函数
        created:function(){
            let domain='http://www.duans.top';
            this.$http.post(domain+'/freeApi/music.php?act=musicRankings',{},{ emulateJSON: true }).then((res)=>{
                // console.log(res);
                if(res.status==200){
                    this.list=res.body.result;
                }
                console.log(this.list);
            }); 
        }
    });
</script>
</html>